package cn.cnic.user.component.system.service.Impl;


import cn.cnic.user.component.system.mapper.ConstantMapper;
import cn.cnic.user.component.system.model.Constant;
import cn.cnic.user.component.system.service.IConstantServices;
import cn.cnic.user.utils.JsonUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class ConstantServicesImpl implements IConstantServices {

    @Resource
    private ConstantMapper constantMapper;

    public String selectByNamespace() {
        Map<String, Object> rtnMap = new HashMap<String, Object>();
        rtnMap.put("code", 500);
        rtnMap.put("errMsg", "常量表查询失败");
        List<Constant> genderInfo = constantMapper.selectByNamespace("gender");
        List<Constant> politicCountenance = constantMapper.selectByNamespace("politicCountenance");
        List<Constant> nation = constantMapper.selectByNamespace("nation");
        List<Constant> country = constantMapper.selectByNamespace("country");
        List<Constant> title = constantMapper.selectByNamespace("title");
        List<Constant> academicDegree = constantMapper.selectByNamespace("academicDegree");
        List<Constant> outstanding = constantMapper.selectByNamespace("outstanding");


        if( !genderInfo.isEmpty() ||  !nation.isEmpty() || !politicCountenance.isEmpty()){
            rtnMap.put("gender",genderInfo);
            rtnMap.put("nation",nation);
            rtnMap.put("politicCountenance",politicCountenance);
            rtnMap.put("country",country);
            rtnMap.put("title",title);
            rtnMap.put("academicDegree",academicDegree);
            rtnMap.put("outstanding",outstanding);
            rtnMap.put("code", 200);
            rtnMap.put("errMsg", "常量表查询成功");
        }
        return JsonUtils.toJsonNoException(rtnMap);
    }


}

